today=int(input())
during=int(input())
meet_day=(today + during)%7
print(meet_day)